package com.ruoyi.sys.lonin.controller;

import cn.hutool.extra.qrcode.QrCodeUtil;
import com.ruoyi.sys.lonin.entity.WeChatPerson;
import com.ruoyi.sys.lonin.util.WxUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author JinSuo
 * @version 1.0
 * @description: TODO
 * @throws
 * @date 2022.5.27 15:40
 */
@RestController
@RequestMapping("/weichat")
public class WeiChatController {
    /**
     * 前端扫描二维码授权成功，取到code后，由微信端回调本地址
     *
     * @author js
     * @param code
     * @param state
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/pcLogin")
    public String pcCallback(String code, String state, HttpServletRequest
            request, HttpServletResponse response,
                             HttpSession session) throws Exception {
        System.out.println("后端端口访问成功");
        WeChatPerson login = WxUtils.getLogin("wxf7e091ee9bf33827", "a079b1d0a41b2fc88cc02b89fa84fabd", code);
        request.getRequestDispatcher("http://localhost:81/index").forward(request, response);
        return "登录成功";
    }


}
